import 'package:flutter/material.dart';
import 'post.dart';
class MyTable extends StatelessWidget{
  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return Scaffold(
      appBar: AppBar(
        title: Text("table数据表格"),
      ),
      body: Container(
        width: double.infinity,
        child: ListView(
          children: <Widget>[
            DataTable(
              columns: [
                DataColumn(
                    label: Container(
                      width: 120.0,
                      child: Text('name'),
                    )
                ),
                DataColumn(
                  label: Text('age'),
                ),
                DataColumn(
                  label: Text('country'),
                )
              ],
              rows: posts.map((post) {
                return DataRow(
                    cells: [
                      DataCell(Text(post.title)),
                      DataCell(Text(post.author)),
                      DataCell(Image.network(post.imageUrl))
                    ]
                );
              }
              ).toList(),
            )
          ],
        )
      ),
      );
  }
}

